import type { App } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'


export default function (app: App) {
    app.config.globalProperties.$my = {
        msg(message: string, type: any = 'success', duration = 1500) {
            ElMessage({
                message,
                type,
                duration
            })
        },
        confirm(msg: string) {
            return new Promise((resolve)=> {
                ElMessageBox.confirm(
                    msg,
                    '提示',
                    {
                        confirmButtonText: '确认',
                        cancelButtonText: '取消',
                        type: 'warning',
                        draggable: true,
                    }
                )
                    .then(() => {
                        resolve(true)
                    })
                    .catch(() => {
                        resolve(false)
                    })
            })
            
        }
    }
}